# Maintainer: Chris Brannon <chris@the-brannons.com>
# Contributor: Douglas Soares de Andrade <dsa@aur.archlinux.org>
# Contributor: Angelo Theodorou <encelo@users.sourceforge.net>
# Contributor: SpepS <dreamspepser at yahoo dot it>

pkgname=epydoc
pkgver=3.0.1
pkgrel=2
pkgdesc="A tool for generating API documentation for Python modules, based on their docstrings"
arch=(any)
license=('MIT')
url="http://epydoc.sourceforge.net/"
depends=('python2' 'docutils')
optdepends=('tk: needed for epydocgui' 'texlive-bin: needed for PDF conversion' 'graphviz: needed for graph generation')
source=("http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.gz"
        "handle-docutils-0.6.patch"
        "python26-tokenizer.patch"
        "string-exceptions.patch")
md5sums=('cdd6f6c76dd8bab5e653a343a0544294'
         'cff5c98976a9768e0ce53561dc816bf0'
         'f0fec671b1c9a01c4452ae9c00926787'
         'c942d7bf218d62d5913bd186762093c1')

build() {
  cd "$srcdir/$pkgname-$pkgver"

  # python2 fixes
  sed -i "s|env python|&2|" `grep -Erl "env python" .`

  # patches
  patch -p1 -i ../${source[1]}
  patch -p1 -i ../${source[2]}
  patch -p1 -i ../${source[3]}

  python2 setup.py build
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  python2 setup.py install --root="$pkgdir" --prefix=/usr --optimize=1

  # Man and license
  install -d "$pkgdir/usr/share/man/man1"
  install -m644 man/*.1 "$pkgdir/usr/share/man/man1"
  install -Dm644 LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
